package com.xhh.microfin.dispatch.service.process.impl;

import com.xhh.microfin.dispatch.common.utils.DateTimeUtil;
import com.xhh.microfin.dispatch.model.consts.ProcessConsts;
import com.xhh.microfin.dispatch.model.entity.Task;
import com.xhh.microfin.dispatch.service.process.CommonTaskImpl;
import com.xhh.microfin.dispatch.service.process.IProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: 003035
 * @Date: 2019/1/16
 */
@Service("start")
public class StartTaskImpl extends CommonTaskImpl {

    private static Logger logger = LoggerFactory.getLogger(StartTaskImpl.class);

    @Autowired
    private IProcess process;

    @Override
    protected boolean busOnActive(ProcessContext context) {

        logger.info("process start, business id is {}" ,context.getBusinessId());
        return true;
    }

    @Override
    protected boolean doneBusiness(Task task, ProcessContext context) {

        process.addTaskVar(context, new Var(ProcessConsts.TASK_SUCCESS,ProcessConsts.TRUE,DateTimeUtil.getNowSeconds()));
        return true;
    }
}
